package com.srd.phone.mvp.presenters;

import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.srd.phone.mvp.interfaces.IBaseView;


public class TabHomePresenter extends BasePresenter {

    public TabHomePresenter(RequestQueue requestQueue, IBaseView iView0) {
        super(requestQueue, iView0);
    }

    /**
     * 公告资讯数据
     */
    public void setNoticeData() {

    }

    /**
     * 平台 投资，收益，注册人数
     *
     * @param tv
     * @param strs
     */
    public void setTextSpan(TextView tv, String... strs) {
        tv.setText(strs[0] + "\n");
        String value = strs[1];
        SpannableString sb = new SpannableString(value);
        sb.setSpan(new AbsoluteSizeSpan(14, true), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        sb.setSpan(new ForegroundColorSpan(Color.parseColor("#E97D1F")), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv.append(sb);
        value = strs[2];
        sb = new SpannableString(value);
        sb.setSpan(new AbsoluteSizeSpan(11, true), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        sb.setSpan(new ForegroundColorSpan(Color.parseColor("#000000")), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv.append(sb);
        tv.setHighlightColor(Color.TRANSPARENT);
    }

    /**
     * 我的账户 投资，收益，可用金额
     *
     * @param tv
     * @param strs
     */
    public void setPersonTextSpan(TextView tv, String strs) {
        tv.append("\n");
        String value = strs;
        SpannableString sb = new SpannableString(value);
        sb.setSpan(new AbsoluteSizeSpan(20, true), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        sb.setSpan(new ForegroundColorSpan(Color.parseColor("#bf1829")), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv.append(sb);
        tv.setHighlightColor(Color.TRANSPARENT);
    }

    public String getFormatMoney(double value) {
        if (value < 10000) {
            return value + "";
        } else if (value < 100000000) {
            double d = value / 10000;
            return String.format("%.2f", d) + "万";
        } else {
            double d = value / 100000000;
            return String.format("%.2f", d) + "亿";
        }
    }

}
